//
//  RWDispatchTool.m
//  RWTool
//
//  Created by Ray on 2018/6/20.
//  Copyright © 2018年 wyl. All rights reserved.
//

#import "RWDispatchTool.h"

void RWGASYNC(dispatch_block_t block) {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
}

void RWMASYNC(dispatch_block_t block) {
    if (dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) == dispatch_queue_get_label(dispatch_get_main_queue())) {
        block();
    } else {
        dispatch_async(dispatch_get_main_queue(), block);
    }
}

void RWAFTERMAIN(CGFloat sec, dispatch_block_t block) {
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(sec * NSEC_PER_SEC)),
                   dispatch_get_main_queue(),
                   block);
}
